package com.sunfeng.netty.atguigu2.nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

/**
 * @author sunfeng
 * @date 2021/03/22 17:22
 **/
public class NIOFileChannel04 {
    public static void main(String[] args) throws Exception {
        FileInputStream fileInputStream = new FileInputStream("d:\\a.jpg");

        FileChannel sourceCh = fileInputStream.getChannel();

        FileOutputStream fileOutputStream = new FileOutputStream("d:\\b.jpg");


        FileChannel destCh = fileOutputStream.getChannel();
        // 使用transferform完成copy
        destCh.transferFrom(sourceCh,0,sourceCh.size());

        fileInputStream.close();
        fileOutputStream.close();
    }
}
